# 元组创建
tup = (1,2,3,4,5)
print(tup)

tup1 = tuple(range(1,9))
print(tup1)

tup2 = (i for i in range(1,5))
print(tup2)
print(tup2.__next__())
tup2= list(tup2)
print(tup2)
# 由于tup2 调用了一次。__next__(),所以第一个数就没有了， 遍历元组
for item in tup2:
    print(item)
# 循环完以后再调用__next__(),则会报错，因为没有元素了
# print(tup2.__next__())

# 元组不可添加元素
# tup1.append(13)
# print(tup1)
# tup1.insert(0,15)
# print(tup1)

# 元组不可删除某个元素
# tup2.pop('ef')
# print(tup2)

# 切片
res = tup1[0:5]
#  res[0]= '12' 元组不可修改值
print(res)
print(tup1)

# 元组长度
print(len(tup1),'===len')

# 获取指定位置的元素
print(tup1.index(3),'===index')

# 获取元组中最大值
print(max(tup1),'==max')

# 获取元组中最小值
print(min(tup1),'==min')

# 获取元组中某个元素出现的次数
print(tup1.count(3),'===count')

# 某个元素是否存在元组中
print( 2 in tup1,'=====in')

# 某个元素不存在元组中
print(2 not in tup1,'=====not in')

# 元组中不可删除元素
# tup1.remove('2')
# print(tup1)
# 元组不可翻转
# tup3 = tup1.reverse()
# print(tup3)
# 元组不可复制
# tup3 = tup1.copy()
# print(tup3)
# 元组也不可清空
# tup1.clear()
# print(tup1)
#不可排序
# tup1.sort()
# print(tup1)